# -*- coding:utf-8 -*-
class Solution(object):
    def maxArea(self, height):
        """
        :type height: List[int]
        :rtype: int
        """
        res = 0
        i, j = 0, len(height) - 1
        while i<j :
            tmp = self.cal(i,j,height[i], height[j])

            if height[i] > height[j]:
                j -= 1
            else:
                i += 1
            if tmp > res:
                res = tmp
                
        return res

    def cal(self, i, j, hi, hj):
        if hi > hj:
            sm = hj
        else:
            sm = hi
        return sm*(j-i)

if __name__ == "__main__":
    print Solution().maxArea([2,1])